#pragma once

#include <algorithm>

#include <gl/glew.h>

#include "VertexBufferAttribute.h"
#include "VertexBufferAttributes.h"
#include "VertexBuffer.h"

#include "VertexBufferGL3x.h"

namespace Renderer
{
	class Device;
	namespace GL3x
	{
		/*
		struct VertexBufferAttributeGL3x : public VertexBufferAttribute
		{
		public:
			VertexBufferAttributeGL3x(VertexBuffer* vertexBuffer, ComponentDatatype componentDatatype, int numberOfComponents)
				: VertexBufferAttribute(vertexBuffer,componentDatatype,numberOfComponents)
			{
				
			}

			VertexBufferAttributeGL3x(
				VertexBuffer* vertexBuffer,
				ComponentDatatype componentDatatype,
				int numberOfComponents,
				bool normalize,
				int offsetInBytes,
				int strideInBytes)
				: VertexBufferAttribute(vertexBuffer,componentDatatype,numberOfComponents,normalize,offsetInBytes,strideInBytes)
			{
				
			}

		public:

			bool Dirty;	//
		};
		
		typedef VertexBufferAttributeGL3x* Ptr_VertexBufferAttributeGL3x;
		*/

		class VertexBufferAttributeGL3x
		{
		public:
			VertexBufferAttributeGL3x();

			bool GetDirty() const;

			void SetDirty(bool dirty);

			VertexBufferAttribute* GetVertexBufferAttribute() const;

			void SetVertexBufferAttribute(VertexBufferAttribute* vertexBufferAttribute);

		private:
			bool _dirty;
			VertexBufferAttribute* _vertexBufferAttribute;
		};


		class VertexBufferAttributesGL3x : public VertexBufferAttributes
		{
		public:
			VertexBufferAttributesGL3x();

			virtual VertexBufferAttribute* GetAt(const unsigned int& index);

			virtual void SetAt(const unsigned int& index, VertexBufferAttribute* value);

			virtual int GetCount() const;
			
			virtual int GetMaximumCount() const;

			virtual std::vector<VertexBufferAttributeGL3x*>& GetAttributes();

			void Clean();

			void Attach(int index);

			static void Detach(int index);

			int GetMaximumArrayIndex();

			static int GetNumberOfVertices(VertexBufferAttribute& attribute);


		private:
			bool _dirty;
			std::vector<VertexBufferAttributeGL3x*> _attributes;

			int _maximumArrayIndex;
		}; 
	}
}